package com.compass.mobile.ui.activity

import UserInfoManager
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import com.compass.mobile.databinding.ActivityComplaintBinding
import com.compass.mobile.framework.base.BaseVBActivity
import com.compass.mobile.framework.ext.onClick
import com.compass.mobile.framework.utils.FocusViewUtils
import com.compass.mobile.ui.viewModel.UserViewModel

/**
 * Description： 投诉建议 --作废
 * Date:2024/6/20 10:30
 */
class ComplaintActivity : BaseVBActivity<ActivityComplaintBinding>() {

    private val userViewModel : UserViewModel  by viewModels()
    companion object {
        fun start(context: Context) {
            val intent = Intent(context, ComplaintActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun initView(savedInstanceState: Bundle?) {
        userViewModel.addInformationLiveData.observe(this){
           if(it){
               showToast("提交成功")
               this.finish()
           }
        }
//        FocusViewUtils.scaleView(mBinding.tvSave,1)
    }

    override fun intListener() {
        mBinding.tvSave.onClick {
            //保存投诉建议
            val content = mBinding.editComplaint.text.toString().trim()
            val mobile = mBinding.etPhone.text.toString().trim()
            if(content.isEmpty()){
                showToast("请输入建议内容")
                return@onClick
            }
            if(mobile.isEmpty()){
                showToast("请输入联系方式")
                return@onClick
            }
            userViewModel.saveInformationData(content,mobile)
        }
    }

    override fun initData() {
        val mobile = UserInfoManager.getPatientInfo()?.mobile
        mBinding.etPhone.setText(mobile)
    }


}